/*
 * functionsFAT.h
 *
 *  Created on: 14/09/2011
 *      Author: utn_so
 */

#ifndef FUNCTIONSFAT_H_
#define FUNCTIONSFAT_H_

#include "structsFAT.h"
#include <stdint.h>
#include "../../General/Stream/stream.h"

int readBufferFromCluster(CLUSTER cluster, int32_t ReadBytes, STREAM * outStream, const char * pathFile, int32_t aOffset);
int writeBufferToCluster(CLUSTER cluster, STREAM * buffer, const char * pathFile);
CLUSTER getRootCluster();
void setSizeOfCluster(int32_t value);
int32_t getSizeOfCluster();
int32_t getSizeOfSector();
void getListOfFreeClusters(Fifo_CLUSTER * clusterList, int32_t CantFreeClusters);
void setCantFreeAndBusyClusters(int32_t * CantFreeClusters, int32_t * CantBusyClusters);

//Pedidos a FileAllocationTable
int EOC(CLUSTER aCluster);
CLUSTER NextCluster(CLUSTER aCluster);
CLUSTER getCluster(CLUSTER aCluster);
void setCluster(CLUSTER aCluster, CLUSTER newValue);
int setFileAllocationTable();
void freeFileAllocationTable();
int UpdateFileAllocationTable();
int UpdateFileAllocationTable_(BLOQUE aBloque);
int32_t getSizeFileAllocationTable();

void FIFO_CLUSTER_Create(Fifo_CLUSTER  * aClusterList);
void FIFO_CLUSTER_Push(Fifo_CLUSTER * aClusterList, CLUSTER aCluster);
void FIFO_CLUSTER_Destroy(Fifo_CLUSTER * aClusterList);

int setInfoBootSector();
int FreeChainCluster(CLUSTER firstCluster);
void getAndSetListOfFreeClusters(Fifo_CLUSTER * clusterList, int32_t CantFreeClusters);
void getChainClusters(CLUSTER firstCluster, Fifo_CLUSTER * clusterList, uint32_t *cantClusters);

#endif /* FUNCTIONSFAT_H_ */
